<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>订单管理系统</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/my_css.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="my-logo">订单管理系统</div>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">功能列表</a>
                    <dl id="function_list" class="layui-nav-child">

                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <iframe src="" name="container" width="100%" height="100%"></iframe>
    </div>

</div>

<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="layui/lay/modules/jquery.js"></script>
<script type="text/javascript">
    // JavaScript代码区域
    layui.use('element', function() {
        let $ = layui.jquery;
        let element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        //触发事件
        let active = {
            tabAdd: function() {
                //新增一个Tab项
                element.tabAdd('demo', {
                    title: '新选项'+ (Math.random()*1000|0) //用于演示
                    ,content: '内容'+ (Math.random()*1000|0)
                    ,id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                })
            }
            ,tabDelete: function(othis){
                //删除指定Tab项
                element.tabDelete('demo', '44'); //删除：“商品管理”
                othis.addClass('layui-btn-disabled');
            }
            ,tabChange: function(){
                //切换到指定Tab项
                element.tabChange('demo', '22'); //切换到：用户管理
            }
        };
    });
</script>
<script type="text/javascript">
    $.ajax({
        url: 'get_user_type',
        method: 'get',
        success: function (user_type) {
            switch (user_type) {
                // 普通用户
                case 0: {
                    let fl = "<dd><a href=\"order_manage0.html\" target=\"container\">我的订单</a></dd>" +
                        "<dd><a href=\"add_order.html\" target=\"container\">添加订单</a></dd>";
                    $('#function_list').html(fl);
                    break;
                }
                // 商家用户
                case 1: {
                    let fl = "<dd><a href=\"order_manage1.html\" target=\"container\">我的订单</a></dd>" +
                        "<dd><a href=\"query_stock.html\" target=\"container\">查询库存</a></dd>" +
                        "<dd><a href=\"update_stock.html\" target=\"container\">更新库存</a></dd>"
                    $('#function_list').html(fl);
                    break;
                }
                // 物流人员
                case 2: {
                    let fl = "<dd><a href=\"order_manage2.html\" target=\"container\">我的订单</a></dd>"
                    $('#function_list').html(fl);
                    break;
                }
            }
        },
        error: function () {
            layer.msg('获取用户类型错误!', {
                icon: 2,
                time: 2000
            });
        }
    });
</script>
</body>
</html>